import { request } from '../request';

/**
 * Login
 *
 * @param userName User name
 * @param password Password
 */
export function fetchGetAllInventory(params?: Api.SystemManage.UserSearchParams) {
  return request<Api.Food.InventoryList>({
    url: '/inventory',
    method: 'get',
    params
  });
}

/**
 * Refresh token
 *
 * @param refreshToken Refresh token
 */
export function fetchAddInventory(data?: Api.Food.Inventory) {
  return request<Api.Food.Inventory>({
    url: '/inventory',
    method: 'post',
    data
  });
}

export function fetchDeleteInventory(id: number) {
  return request<Api.Food.Inventory>({
    url: `/${id}/inventory`,
    method: 'delete'
  });
}

export function fetchDeleteBatchInventory(ids: string[]) {
  return request<Api.Food.Inventory>({
    url: `/inventory`,
    method: 'delete',
    data: {
      ids
    }
  });
}

export function fetchEditInventory(id: number, data?: Api.Food.Inventory) {
  return request<Api.Food.Inventory>({
    url: `/${id}/inventory`,
    method: 'put',
    data
  });
}
